﻿<Window x:Class="BizControl.Presentation.Shell.ModelSelector"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:viewmodels="clr-namespace:BizControl.Presentation.Shell.ViewModels"
        xmlns:res="clr-namespace:BizControl.Presentation.Infrastructure.Properties;assembly=BizControl.Presentation.Infrastructure"
        xmlns:csla="clr-namespace:Csla.Xaml;assembly=Csla.Xaml"
        Background="Transparent" WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize" AllowsTransparency="True" SizeToContent="WidthAndHeight"
        Title="{x:Static res:Captions.BizControlMainModelChoice}"
        BorderBrush="{StaticResource MainBorderBrush}" BorderThickness="2"
        MinHeight="150" MinWidth="200"
        WindowStyle="None"
        x:Name="ModelSelectorWindow">
    
    <Window.Resources>
        <DataTemplate x:Key="ModelComboBoxTemplate">
            <Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource BorderLightBrush}">
                <TextBlock Text="{Binding Path=Model.Name}" TextWrapping="Wrap" MaxWidth="300"
                           TextAlignment="Left" HorizontalAlignment="Center" VerticalAlignment="Center" />
            </Border>
        </DataTemplate>
    </Window.Resources>

    <Grid Background="{StaticResource MainBackgroundBrush}">
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
            <TextBlock HorizontalAlignment="Center" Background="Transparent" VerticalAlignment="Top" 
                       TextAlignment="Center"
                       FontSize="18" FontWeight="Bold" Foreground="Black" TextWrapping="Wrap"
                       Text="{x:Static res:Captions.ModelChoice}" Width="120" Margin="80,6,50,0">
    		    <TextBlock.Effect>
    			    <DropShadowEffect Color="DarkGray" />
    		    </TextBlock.Effect>
            </TextBlock>
            <StackPanel Margin="11,60,11,0">
                <ComboBox ItemsSource="{Binding Path=CurrentPerson.Models}"
                          VerticalAlignment="Top" Width="150"
                          SelectedItem="{Binding ElementName=ModelSelectorWindow, Mode=TwoWay, Path=DataContext.CurrentModel}"
                          ItemTemplate="{StaticResource ModelComboBoxTemplate}" />
                <TextBlock HorizontalAlignment="Center" Foreground="DarkGray" 
                           Text="{x:Static res:Captions.Model}" />
                <StackPanel Margin="0,8,0,10" Orientation="Horizontal" HorizontalAlignment="Center">
                    <TextBlock>
                        <Hyperlink Click="EnterButton" IsEnabled="{Binding Path=CanEnter}"
                                   ToolTip="{x:Static res:Captions.SelectModel}">
                            <TextBlock Text="{x:Static res:Captions.SelectButtonCaption}" />
                        </Hyperlink>
                    </TextBlock>
                    <TextBlock Margin="20,0,0,0">
                        <Hyperlink Click="CancelButton" ToolTip="{x:Static res:Captions.ExitProgram}">
                            <TextBlock Text="{x:Static res:Captions.ExitButtonCaption}" />
                        </Hyperlink>
                    </TextBlock>
                </StackPanel>
                <Button Height="25" Width="25"
                        ToolTip="{x:Static res:Captions.AddModel}"
                        Click="AddModelButton"
                        Command="{Binding Path=AddModelCommand}"
                        HorizontalAlignment="Right" VerticalAlignment="Bottom" 
                        Content="{StaticResource PlusPath}"/>
                <StackPanel x:Name="AddingModelStackPanel" Margin="0,8,0,10" Visibility="Collapsed">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                        <TextBox VerticalAlignment="Top" Width="150" x:Name="ModelNameTextBox"
                                 Text="{Binding Path=ModelName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                 ToolTip="{x:Static res:Captions.PromptModelName}" />
                        <!--<csla:PropertyStatus DataContext="{Binding Path=NewModel}" Property="{Binding Path=Name}"/>-->
                    </StackPanel>
                    <TextBlock HorizontalAlignment="Center" Foreground="DarkGray" 
                               Text="{x:Static res:Captions.ModelName}" />
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8,0,10">
                        <TextBlock HorizontalAlignment="Center">
                            <Hyperlink Click="SaveButton" Command="{Binding Path=SaveModelCommand}">
                                <TextBlock Text="{x:Static res:Captions.SaveButtonCaption}" 
                                           ToolTip="{x:Static res:Captions.SaveModel}" />
                            </Hyperlink>
                        </TextBlock>
                        <Grid>
                            <ContentControl Width="20" Height="20">
                                <ContentControl.Style>
                                    <Style TargetType="ContentControl">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=CanSaveModelProp}" Value="True">
                                                <Setter Property="ContentControl.Content" Value="{StaticResource OkPath}" />
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding Path=CanSaveModelProp}" Value="False">
                                                <Setter Property="ContentControl.Content" Value="{StaticResource CancelPath}" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </ContentControl.Style>
                            </ContentControl>
                        </Grid>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </Grid>
    </Grid>
</Window>
